package com.hy.mydesktop.shared.rpc.util;

import com.hy.mydesktop.client.component.meta.GxtComponentMetaModel;
import com.hy.mydesktop.client.component.meta.GxtComponentMetaNodeModel;
import com.hy.mydesktop.client.component.type.ComponentControllerEnum;
import com.hy.mydesktop.client.component.type.ComponentTypeEnum;

public class ComponentTypeEnumConverter {
	
	
	public static GxtComponentMetaModel updateComponentTypeEnum(GxtComponentMetaModel gxtComponentMetaModel) {
		for (GxtComponentMetaNodeModel gxtComponentMetaNodeModel : gxtComponentMetaModel.getList()) {
			updateComponentTypeEnum(gxtComponentMetaNodeModel);
		}
		return gxtComponentMetaModel;
	}
	/**
	 * 
	 * <ul>
	 * <li>方法含义：根据componentTypeEnumIndex，设置GxtComponentMetaNodeModel的ComponentTypeEnum</li>
	 * <li>方法作者：花宏宇</li>
	 * <li>编写日期：2010-10-26；时间：下午上午10:21:36</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @param gxtComponentMetaNodeModel
	 * @return
	 */
	public static GxtComponentMetaNodeModel updateComponentTypeEnum(GxtComponentMetaNodeModel gxtComponentMetaNodeModel) {
		gxtComponentMetaNodeModel.setComponentTypeEnum(getComponentTypeEnum(gxtComponentMetaNodeModel.getComponentTypeEnumIndex()));
		return gxtComponentMetaNodeModel;
	}
	
	public static ComponentTypeEnum getComponentTypeEnum(int componentTypeEnumIndex) {
		GxtComponentMetaNodeModel gxtComponentMetaNodeModel = new GxtComponentMetaNodeModel();
		
		switch (componentTypeEnumIndex) {
			case 0://ComponentControllerEnum.TREEPANELMODULES_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.TREEPANELMODULES_MODEL);
				break;

			case 1://ComponentTypeEnum.GRIDSETMODULES_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.GRIDSETMODULES_MODEL);				
				break;

			case 2://ComponentTypeEnum.GRID_MODULE_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.GRIDMODULE_MODEL);				
				break;

			case 3://ComponentTypeEnum.TREE_DATALOAD_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.TREEGRIDMODULE_MODEL);				
				break;
							
			case 4://ComponentTypeEnum.GRID_DATALOAD_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.FORM_SETMODULES_MODEL);								
				break;				
			case 5://ComponentTypeEnum.DATALOAD_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.FORM_MODULE_MODEL);								
				break;
				
			case 6://ComponentTypeEnum.GRID_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.DESKTOP_MODEL);								
				break;
			case 7://ComponentTypeEnum.DATEFIELD_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.DESKTOP_STARTMENU_MODEL);								
				break;
				
			case 8://ComponentTypeEnum.COMBOBOX_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.DESKTOP_MENUITEM_MODEL);								
				break;
				
			//case XXX6:
			//	gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.DATALOAD_CONTROLLER_MODEL);								
			//	break;
				
			case 9://ComponentTypeEnum.FORMSET_MODULE_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.SHORTCUT_MODEL);
				break;
				
			case 10://ComponentTypeEnum.FORMMODULE_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.FITLAYOUT_MODEL);
				break;
				
			case 11://ComponentTypeEnum.DESKTOP_STARTMENU_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.ACCORDIONLAYOUT_MODEL);
				break;
				
			
				
			case 12://ComponentTypeEnum.TEXTFIELD_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.ROWLAYOUT_MODEL);
				break;

			case 13://ComponentTypeEnum.FORMPANEL_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.VBOXLAYOUT_MODEL);
				break;
				
			case 14://ComponentTypeEnum.TOOLBAR_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.COLUMNLAYOUT_MODEL);
				break;
				
			case 15://ComponentTypeEnum.MENUBAR_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.FLOWLAYOUT_MODEL);
				break;
				
			case 16://ComponentTypeEnum.DESKTOP_MENUITEM_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.TABLELAYOUT_MODEL);
				break;
			case 17://ComponentTypeEnum.CONTENTPANEL_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.FORMLAYOUT_MODEL);
				break;
				
			case 18://ComponentTypeEnum.WINDOW_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.SHORTCUTKEY_MODEL);
				break;
			case 19://ComponentTypeEnum.DESKTOP_CONTROL_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.MESSAGEBOX_MODEL);
				break;
				
			case 20://ComponentTypeEnum.DATALOAD_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.WINDOW_MODEL);
				break;
			case 21://ComponentControllerEnum.GRIDSETMODULES_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.TEXTFIELD_MODEL);				
				break;

			case 22://ComponentTypeEnum.GRID_MODULE_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.CONTENTPANEL_MODEL);				
				break;

			case 23://ComponentTypeEnum.TREE_DATALOAD_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.TOOLBAR_MODEL);				
				break;
							
			case 24://ComponentTypeEnum.GRID_DATALOAD_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.BUTTON_MODEL);								
				break;				
			case 25://ComponentTypeEnum.DATALOAD_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.BASEGRID_MODEL);								
				break;
				
			case 26://ComponentTypeEnum.GRID_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.GRID_MODEL);								
				break;
			case 27://ComponentTypeEnum.DATEFIELD_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.TREE_MODEL);								
				break;
				
			case 28://ComponentTypeEnum.COMBOBOX_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.CHART_MODEL);								
				break;
				
			//case XXX6:
			//	gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.DATALOAD_Type_MODEL);								
			//	break;
				
			case 29://ComponentTypeEnum.FORMSET_MODULE_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.LAYOUT_MODEL);
				break;
				
			case 30://ComponentTypeEnum.FORMMODULE_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.MENU_MODEL);
				break;
				
			case 31://ComponentTypeEnum.DESKTOP_STARTMENU_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.MENUITEM_MODEL);
				break;
				
			
				
			case 32://ComponentTypeEnum.TEXTFIELD_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.MENUBAR_MODEL);
				break;

			case 33://ComponentTypeEnum.FORMPANEL_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.MENUBARITEM_MODEL);
				break;
				
			case 34://ComponentTypeEnum.TOOLBAR_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.FIELDSET_MODEL);
				break;
				
			case 35://ComponentTypeEnum.MENUBAR_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.DATEFIELD_MODEL);
				break;
				
			case 36://ComponentTypeEnum.DESKTOP_MENUITEM_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.DATEPICKER_MODEL);
				break;
			case 37://ComponentTypeEnum.CONTENTPANEL_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.COMBOBOX_MODEL);
				break;
				
			case 38://ComponentTypeEnum.WINDOW_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.CHECKBOX_MODEL);
				break;
			case 39://ComponentTypeEnum.DESKTOP_CONTROL_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.CHECKBOXGROUP_MODEL);
				break;
				
			case 40://ComponentTypeEnum.DATALOAD_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.EDITABLEGRID_MODEL);
				break;
			case 41://ComponentControllerEnum.GRIDSETMODULES_CONTROLLER_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.FILEUPLOAD_MODEL);				
				break;

			case 42://ComponentTypeEnum.GRID_MODULE_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.FORMPANEL_MODEL);				
				break;

			case 43://ComponentTypeEnum.TREE_DATALOAD_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.PAGING_MODEL);				
				break;
							
			case 44://ComponentTypeEnum.GRID_DATALOAD_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.SUGGESTBOX_MODEL);								
				break;				
			case 45://ComponentTypeEnum.DATALOAD_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.TABITEM_MODEL);								
				break;
				
			case 46://ComponentTypeEnum.GRID_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.TABPANEL_MODEL);								
				break;
			case 47://ComponentTypeEnum.DATEFIELD_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.TEXTAREA_MODEL);								
				break;
				
			case 48://ComponentTypeEnum.COMBOBOX_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.ROWDATA_MODEL);								
				break;
				
			//case XXX6:
			//	gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.DATALOAD_Type_MODEL);								
			//	break;
				
			case 49://ComponentTypeEnum.FORMSET_MODULE_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.COLUMNDATA_MODEL);
				break;
				
			case 50://ComponentTypeEnum.FORMMODULE_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.FLOWDATA_MODEL);
				break;
				
			case 51://ComponentTypeEnum.DESKTOP_STARTMENU_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.TABLEDATA_MODEL);
				break;
				
			
				
			case 52://ComponentTypeEnum.TEXTFIELD_Type_MODEL.ordinal():
				gxtComponentMetaNodeModel.setComponentTypeEnum(ComponentTypeEnum.FORMDATA_MODEL);
				break;

			
			default:
				assert false : "Error converting ComponentTypeEnumIndex to ComponentTypeEnum : ComponentTypeEnumIndex = "+componentTypeEnumIndex;
				break;
		}
		return gxtComponentMetaNodeModel.getComponentTypeEnum();
		
	}


}
